<!-- list.jsp -->
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>健康食谱 - 绿色系列表</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --primary-green: #4CAF50;
            --light-green: #81C784;
            --lighter-green: #A5D6A7;
            --green-bg: #E8F5E9;
            --dark-green: #388E3C;
            --text-color: #333;
            --light-text: #666;
            --white: #fff;
            --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
            --transition: all 0.3s ease;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background-color: var(--green-bg);
            color: var(--text-color);
            line-height: 1.6;
            padding-bottom: 60px;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }

        /* 页面标题 */
        .page-header {
            text-align: center;
            margin-bottom: 30px;
            position: relative;
        }

        .page-header h1 {
            color: var(--dark-green);
            font-size: 2.5rem;
            font-weight: 700;
            display: inline-block;
            padding-bottom: 10px;
        }

        .page-header h1::after {
            content: "";
            position: absolute;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 100px;
            height: 4px;
            background: linear-gradient(to right, var(--primary-green), var(--light-green));
            border-radius: 2px;
        }

        .page-header p {
            color: var(--light-text);
            margin-top: 10px;
            font-size: 1.1rem;
        }

        /* 搜索栏 */
        .search-container {
            display: flex;
            justify-content: center;
            margin-bottom: 30px;
            position: relative;
        }

        .search-box {
            width: 100%;
            max-width: 500px;
            padding: 12px 15px;
            padding-left: 45px;
            border: 2px solid var(--lighter-green);
            border-radius: 30px;
            font-size: 1rem;
            outline: none;
            transition: var(--transition);
            background-color: var(--white);
            box-shadow: var(--shadow);
        }

        .search-box:focus {
            border-color: var(--primary-green);
            box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
        }

        .search-box::placeholder {
            color: #9E9E9E;
        }

        .search-icon {
            position: absolute;
            left: 18px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--light-text);
            font-size: 1.2rem;
        }

        /* 食谱表格 */
        .recipe-table {
            width: 100%;
            border-collapse: collapse;
            background-color: var(--white);
            border-radius: 10px;
            overflow: hidden;
            box-shadow: var(--shadow);
        }

        .recipe-table thead {
            background: linear-gradient(to right, var(--primary-green), var(--light-green));
            color: var(--white);
        }

        .recipe-table th {
            padding: 15px 20px;
            text-align: left;
            font-weight: 600;
            position: relative;
        }

        .recipe-table th::after {
            content: "";
            position: absolute;
            right: 0;
            top: 50%;
            height: 60%;
            border-right: 1px solid rgba(255, 255, 255, 0.3);
        }

        .recipe-table th:last-child::after {
            display: none;
        }

        .recipe-table tbody tr {
            border-bottom: 1px solid #E0E0E0;
            transition: var(--transition);
        }

        .recipe-table tbody tr:hover {
            background-color: #F5F9F6;
            transform: translateY(-2px);
        }

        .recipe-table td {
            padding: 15px 20px;
            vertical-align: middle;
        }

        .recipe-table .recipe-image {
            width: 60px;
            height: 60px;
            border-radius: 8px;
            overflow: hidden;
            object-fit: cover;
            border: 1px solid #E0E0E0;
        }

        .recipe-table .recipe-type {
            display: inline-block;
            padding: 4px 10px;
            background-color: var(--lighter-green);
            color: var(--dark-green);
            border-radius: 20px;
            font-size: 0.85rem;
            font-weight: 500;
        }

        .recipe-table .recipe-calories {
            color: var(--primary-green);
            font-weight: 600;
        }

        /* 分页控件 */
        .pagination {
            display: flex;
            justify-content: center;
            margin-top: 30px;
            gap: 10px;
        }

        .page-btn {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            border: 1px solid var(--lighter-green);
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-color);
            text-decoration: none;
            transition: var(--transition);
            background-color: var(--white);
        }

        .page-btn:hover, .page-btn.active {
            background: linear-gradient(to right, var(--primary-green), var(--light-green));
            color: var(--white);
            border-color: var(--primary-green);
            box-shadow: var(--shadow);
        }

        .page-btn i {
            font-size: 0.9rem;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .page-header h1 {
                font-size: 2rem;
            }

            .recipe-table th, .recipe-table td {
                padding: 12px 15px;
                font-size: 0.9rem;
            }

            .recipe-table .recipe-image {
                width: 50px;
                height: 50px;
            }
        }

        @media (max-width: 576px) {
            .recipe-table {
                display: block;
                overflow-x: auto;
            }

            .page-header h1 {
                font-size: 1.8rem;
            }
        }
    </style>
</head>
<body>
<div class="container">
    <div class="page-header">
        <h1>健康食谱列表</h1>
        <p>探索丰富的绿色健康食谱，享受营养美味的饮食</p>
    </div>

    <div class="search-container">
        <i class="fas fa-search search-icon"></i>
        <input type="text" class="search-box" placeholder="搜索食谱名称、类型...">
    </div>

    <table class="recipe-table">
        <thead>
        <tr>
            <th>ID</th>
            <th>食谱名称</th>
            <th>类型</th>
            <th>分类ID</th>
            <th>卡路里</th>
            <th>蛋白质</th>
            <th>碳水化合物</th>
            <th>图片</th>
            <th>描述</th>
            <th>创建时间</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${foodsrecipes}" var="recipe">
            <tr>
                <td>${recipe.recipeid}</td>
                <td>${recipe.recipename}</td>
                <td><span class="recipe-type">${recipe.type}</span></td>
                <td>${recipe.categoryid}</td>
                <td class="recipe-calories">${recipe.calories} kcal</td>
                <td>${recipe.protein} g</td>
                <td>${recipe.carbs} g</td>
                <td><img src="${recipe.img}" alt="${recipe.recipename}" class="recipe-image"></td>
                <td>${recipe.description}</td>
                <td>${recipe.createtime}</td>
            </tr>
        </c:forEach>
        </tbody>
    </table>

    <div class="pagination">
        <a href="#" class="page-btn"><i class="fas fa-chevron-left"></i></a>
        <a href="#" class="page-btn active">1</a>
        <a href="#" class="page-btn">2</a>
        <a href="#" class="page-btn">3</a>
        <a href="#" class="page-btn">4</a>
        <a href="#" class="page-btn">5</a>
        <a href="#" class="page-btn"><i class="fas fa-chevron-right"></i></a>
    </div>
</div>

<script>
    // 简单的交互逻辑
    document.addEventListener('DOMContentLoaded', function() {
        // 搜索框聚焦效果
        const searchBox = document.querySelector('.search-box');
        searchBox.addEventListener('focus', function() {
            this.parentElement.style.transform = 'scale(1.02)';
            this.parentElement.style.transition = 'transform 0.3s ease';
        });

        searchBox.addEventListener('blur', function() {
            this.parentElement.style.transform = 'scale(1)';
        });

        // 分页按钮交互
        const pageBtns = document.querySelectorAll('.page-btn');
        pageBtns.forEach(btn => {
            btn.addEventListener('click', function() {
                pageBtns.forEach(b => b.classList.remove('active'));
                this.classList.add('active');
            });
        });
    });
</script>
</body>
</html>